﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class ZoomUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
    public float zoomSize;
    public float yOffset;
    private Vector3 originalScale; // 原始缩放比例
    private Vector3 originalPosition;
    //OnPointerEnter和OnPointerExit名字固定不可修改
    public void OnPointerEnter(PointerEventData pointerEventData)
    {
        transform.position = new Vector3(transform.position.x, transform.position.y, 0f);
        originalScale = transform.localScale;
        originalPosition = transform.position;

        transform.localScale = new Vector3(zoomSize, zoomSize, 1.0f);
        transform.position = new Vector3(
            transform.position.x,
            originalPosition.y + yOffset,
            transform.position.z
        );
    }
    public void OnPointerExit(PointerEventData pointerEventData)
    {
        transform.localScale = Vector3.one;
        transform.position = originalPosition;
    }
}
